<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="/static/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/static/css/public.css" media="all" />
</head>
<body class="childrenBody">
<div class="layui-row layui-col-space15">
    <script type="text/html" id="toolbarDemo">
    </script>
    <table id="record" lay-filter="record"></table>
</div>
</body>
<script type="text/html" id="RecordToolBar">
    <a class="layui-btn layui-btn-sm layui-bg-cyan" lay-event="result">发送检查结果</a>
</script>
<script type="text/javascript" src="/static/layui/layui.js"></script>
<script>
    layui.use(['table','jquery','form'],function () {
        var table = layui.table,
            form = layui.form,
            $ = layui.jquery;


        var records = table.render({
            elem: "#record",
            url: '/record/listRecord',
            limit: 5,
            limits: [5, 10, 15, 20, 25],
            page: true,
            loading:true,
            response: {
                statusName: 'code'
                , statusCode: 200
                , msgName: 'msg'
                , countName: 'count'
                , dataName: 'data'
            },
            id: 'records',
            cols: [[
                {type: "checkbox", fixed: "left", width: 50, align: 'center'},
                {field: 'id', title: '病例ID', width: 100, align: "center"},
                {field: 'patientNo', title: '患者病号',width:150, align: 'center'},
                {field:'doctorNo', title:'医生号',width:150, align: 'center'},
                {field:'recContext', title:'结果报告',align: 'center'},
                {title:'操作',align:'center',fixed: "right",templet: '#RecordToolBar',width:200}
            ]],
            toolbar:'#toolbarDemo',
            defaultToolbar: ['filter', 'print', 'exports']
        });



        table.on('tool(record)',function (obj) {
            var data = obj.data;
            var layEvent = obj.event;
            if (layEvent === 'result'){//监听修改
                sendResult(data);
            }

        });

        function sendResult(data){
            var index = layui.layer.open({
                title : "发送结果报告",
                type : 2,
                content : "./returns.html",
                success : function(layero, index){
                    var body = layui.layer.getChildFrame('body', index);
                    if(data != null){
                        body.find("#patNo").val(data.patientNo);
                        body.find("#docNo").val(data.doctorNo);
                        body.find("#resContext").val(data.recContext);
                        form.render();
                    }
                    setTimeout(function(){
                        layui.layer.tips('点击此处返回资讯列表', '.layui-layer-setwin .layui-layer-close', {
                            tips: 3
                        });
                    },1000)
                }
            })
            layui.layer.full(index);
            //改变窗口大小时，重置弹窗的宽高，防止超出可视区域
            $(window).on("resize",function(){
                layui.layer.full(index);
            })
        }
    });



</script>